package com.scuec.demo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scuec.demo.entity.StudentInfo;
import com.scuec.demo.mapper.StudentMapper;
import com.scuec.demo.service.StudentService;
import com.scuec.demo.vo.ViewStudentInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;


    @Override
    public List<ViewStudentInfo> findStudentInfo(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<StudentInfo> lists = studentMapper.getStudentInfo();
        PageInfo<StudentInfo> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public PageInfo<StudentInfo> findStudentPages(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<StudentInfo> lists = studentMapper.getStudentInfo();
        PageInfo<StudentInfo> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public List<StudentInfo> getStudentInfo() {
        List<StudentInfo> studentInfoList = studentMapper.getStudentInfo();
        return studentInfoList;
    }

    @Override
    public StudentInfo getStudentInfoById(Integer id) {
        StudentInfo info = studentMapper.getStudentInfoById(id);
        return info;
    }

    @Override
    public int deleteStudentInfoById(Integer id) {
        int i = studentMapper.deleteStudentInfoById(id);
        return i;
    }

    @Override
    public int insertStudentInfo(StudentInfo studentInfo) {
        int i = studentMapper.insertStudentInfo(studentInfo);
        return i;
    }

    @Override
    public int updateStudentInfo(StudentInfo studentInfo) {
        int i = studentMapper.updateStudentInfo(studentInfo);
        return i;
    }
}
